<?php
include_once('models/Search_model.php');
include_once('controllers/frontend_controller.php');
class Search_Controller extends Frontend_Controller{
    public $model;
    public $action = 'lists';
    public function __construct(){
        parent::__construct();
        $this->model = new Search_model();
        if(isset($_GET['action'])) $this->action = $_GET['action'];
        $this->{$this->action}();
    }
    public function result(){
        if(isset($_POST['ok'])){
            $keyword = $_POST['keyword'];
            $category = $_POST['category'];
            if($category == 0){
                $search = $this->model->searchs($keyword);
                include_once 'views/Search/result.php';
            }
            else{
                $search = $this->model->search($keyword,$category);
                include_once 'views/Search/result.php';
            }
        }
    }
}
?>